import { defineStore } from "pinia";
import { ref } from "vue";
import { fetchHotListAPI } from "@/api/hotApi";
import type { PageParams } from "@/types/home";
import type { Hot } from "@/types/hot";


const useHotStore = defineStore("hotStore", () => {
    /*热门推荐的数据*/
    const hot = ref<Hot>(<Hot>{});
    /*获取热门推荐的请求函数*/
    const fetchHotList = async (params: PageParams & { subType?: string }, url: string): Promise<void> => {
        const { result }: { result: Hot } = await fetchHotListAPI(params, url);
        hot.value = result;
    };

    return {
        hot,
        fetchHotList,
    };
});

export default useHotStore;
